// app/controller/upload.js
const Controller = require('egg').Controller;

class UploadController extends Controller {
    async index() {
        const { ctx, service } = this;
        console.log('______________________')
        const stream = await this.ctx.getFileStream();

        console.log(ctx.request)
        console.log(stream)
        this.ctx.success()
        // const { file } = ctx.request.files; // 获取上传的文件
        // const stream = fs.createReadStream(file.filepath); // 创建可读流
        // const targetPath = path.join(__dirname, '../public/uploads/', file.filename); // 设置目标路径
        // const upStream = fs.createWriteStream(targetPath); // 创建可写流
        // stream.pipe(upStream); // 将文件流导入到目标路径
        // this.ctx.success( `/public/uploads/${file.filename}`);
    }
}

module.exports = UploadController;